home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 July / macformat52.iso / mac / Shareware Plus / Developers / YAAF v1.0 alpha 1 / (Sources) / Standard Controls / Images / XGStdIcon.cpp next >
Encoding:
C/C++ Source or Header  |  1997-04-24  |  2.8 KB  |  123 lines

  1. /*    XGStdIcon.cpp
  2.  *
  3.  *        This is the engine for handling drawing color icons
  4.  */
  5.  
  6. /*  YAAF - Yet another application framework
  7.  *  Copyright (C) 1997 William Edward Woody and In Phase Consulting
  8.  *  
  9.  *  This library is free software; you can redistribute it
  10.  *  and/or modify it under the terms of the GNU Library
  11.  *  General Public License as published by the Free Software
  12.  *  Foundation; either version 2 of the License, or any
  13.  *  later version.
  14.  *  
  15.  *  This library is distributed in the hope that it will be
  16.  *  useful, but WITHOUT ANY WARRANTY; without even the implied
  17.  *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
  18.  *  PURPOSE. See the GNU Library General Public License for
  19.  *  more details.
  20.  *  
  21.  *  You should have received a copy of the GNU Library General
  22.  *  Public License along with this library; if not, write to the
  23.  *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24.  *  Boston, MA 02111-1307, USA.
  25.  *  
  26.  *  To contact the author, either e-mail me at
  27.  *  woody@alumni.caltech.edu, or write to us at
  28.  *  
  29.  *          William Edward Woody
  30.  *          In Phase Consulting
  31.  *          1545 Ard Eevin Avenue
  32.  *          Glendale, CA 91202
  33.  */
  34.  
  35. #include <XStdImage.h>
  36.  
  37. /************************************************************************/
  38. /*                                                                        */
  39. /*    Construction/Destruction                                            */
  40. /*                                                                        */
  41. /************************************************************************/
  42.  
  43. /*    XGStdIcon::XGStdIcon
  44.  *
  45.  *        Standard picture initialization
  46.  */
  47.  
  48. XGStdIcon::XGStdIcon(XGView *p, XGArgStream &i) : XGView(p,i)
  49. {
  50.     Init(i.GetInteger());
  51. }
  52.  
  53. XGStdIcon::XGStdIcon(XGView *p, XGSImageInitRecord &i) : XGView(p,i.v)
  54. {
  55.     Init(i.image);
  56. }
  57.  
  58.  
  59. /*    XGStdIcon::~XGStdIcon
  60.  *
  61.  *        Fry this
  62.  */
  63.  
  64. XGStdIcon::~XGStdIcon()
  65. {
  66. #if OPT_MACOS == 1
  67.     if (fColor) {
  68.         if (fCIcon) DisposeCIcon(fCIcon);
  69.     } else {
  70.         if (fIcon) ReleaseResource(fIcon);
  71.     }
  72. #endif
  73. }
  74.  
  75. /************************************************************************/
  76. /*                                                                        */
  77. /*    Image Drawing                                                        */
  78. /*                                                                        */
  79. /************************************************************************/
  80.  
  81. /*    XGStdIcon::DoDrawView
  82.  *
  83.  *        Draw the picture
  84.  */
  85.  
  86. void XGStdIcon::DoDrawView(Rect)
  87. {
  88. #if OPT_MACOS == 1
  89.     Rect r;
  90.     XGDraw draw(this);
  91.     
  92.     r = GetContentRect();
  93.     if (fColor) {
  94.         if (fCIcon) ::PlotCIconHandle(&r,0,0,fCIcon);
  95.     } else {
  96.         if (fIcon)  ::PlotIconHandle(&r,0,0,fIcon);
  97.     }
  98. #endif
  99. }
  100.  
  101. /************************************************************************/
  102. /*                                                                        */
  103. /*    Image Drawing                                                        */
  104. /*                                                                        */
  105. /************************************************************************/
  106.  
  107. /*    XGStdIcon::Init
  108.  *
  109.  *        My initialization routine
  110.  */
  111.  
  112. void XGStdIcon::Init(short resID)
  113. {
  114. #if OPT_MACOS == 1
  115.     fCIcon = GetCIcon(resID);
  116.     if (fCIcon) fColor = true;
  117.     else {
  118.         fColor = false;
  119.         fIcon = GetIcon(resID);
  120.     }
  121. #endif
  122. }
  123.